
#include <mockcpp/mockcpp.hpp>
#include <testngpp/testngpp.hpp>

#include <sstream>

#include <Length.h>
#include <Format.h>
#include <ComboFormat.h>
#include <InchFormat.h>


using namespace std;


USING_MOCKCPP_NS
USING_TESTNGPP_NS

FIXTURE(LengthCalculation)
{
	TEST(should be able to compare 1 mile = 1760 yard)
	{
		ASSERT_TRUE( Length(1, MILE) == Length(1760, YARD) );
	}

	TEST(should be able to compare 1 yard = 3 feet)
	{
		ASSERT_TRUE(Length(1, YARD) == Length(3, FEET) );
	}

	TEST(should be able to compare 1 feet = 12 inch)
	{
		ASSERT_TRUE(Length(1, FEET) ==Length(12, INCH) );
	}

	TEST(should be able to calculate 12 inch + 2feet =  3feet)
	{
		ASSERT_TRUE( Length(12, INCH) + Length(2, FEET) == Length(3, FEET) );
	}

};

FIXTURE(LengthPrint)
{
	TEST(should be able to present "35 INCH" in "2 FEET 11 INCH")
	{
		ostringstream os;
		Length length( 35, INCH );

		length.print( os, COMBO_FORMAT );

		ASSERT_EQ( os.str(), "2 FEET 11 INCH" );
	}

	TEST(should be able to present "38 INCH" in "1 YARD 2 INCH")
	{
		ostringstream os;
		Length length( 38, INCH );

		length.print( os, COMBO_FORMAT );

		ASSERT_EQ( os.str(), "1 YARD 2 INCH" );
	}

	TEST(should be able to present "48 INCH" in "1 YARD 1 FEET")
	{
		ostringstream os;
		Length length( 48, INCH );

		length.print( os, COMBO_FORMAT );

		ASSERT_EQ( os.str(), "1 YARD 1 FEET" );
	}

	TEST(should be able to present "5 FEET" in "1 YARD 2 FEET")
	{
		ostringstream os;
		Length length( 5, FEET );

		length.print( os, COMBO_FORMAT );

		ASSERT_EQ( os.str(), "1 YARD 2 FEET" );
	}

	TEST(should be able to present "1781 YARD" in "1 MILE 21 YARD")
	{
		ostringstream os;
		Length length( 1781, YARD );

		length.print( os, COMBO_FORMAT );

		ASSERT_EQ( os.str(), "1 MILE 21 YARD" );
	}

	TEST(should be able to present "2 INCH" in "2 INCH")
	{
		ostringstream os;
		Length length( 2, INCH );

		length.print( os, INCH_FORMAT );

		ASSERT_EQ( os.str(), "2 INCH" );
	}

	TEST(should be able to present "2 FEET" in "24 INCH")
	{
		ostringstream os;
		Length length( 2, FEET );

		length.print( os, INCH_FORMAT );

		ASSERT_EQ( os.str(), "24 INCH" );
	}

	TEST(should be able to present "3 YARD" in "108 INCH")
	{
		ostringstream os;
		Length length( 3, YARD );

		length.print( os, INCH_FORMAT );

		ASSERT_EQ( os.str(), "108 INCH" );
	}

	TEST(should be able to present "2 MILE" in "126720 INCH")
	{
		ostringstream os;
		Length length( 2, MILE );

		length.print( os, INCH_FORMAT );

		ASSERT_EQ( os.str(), "126720 INCH" );
	}

};

